open(BUFF,"input_withcorrecthead.tped")or die "no file exists\n";
open(WRBUFF,">input_withcorrecthead.ind");
while(<BUFF>)
{
	chomp($_);
	@array=split(" ",$_);
	#print $array[1]."\n";
	$file{$array[1]} = 1;
}
open(BUFF,"/data1/bsi/BORA_processing/tcga_genotyping/ANNOT/affy_annot_1") or die "no file exists\n";
while(<BUFF>)
{
        chomp($_);
        $affy{$_} =1;
}
open(BUFF,"/data1/bsi/BORA_processing/tcga_genotyping/ANNOT/550v3_annot") or die "no file exists\n";
while(<BUFF>)
{
        chomp($_);
	$ill550v3{$_} =1
}

print "done reading file\n";
open(BUFF,"../GBM_normal/final.ind")or die "no file exists\n";

while(<BUFF>)
{
        chomp($_);
        @array=split(" ",$_);
        #print $array[1]."\n";
        #$file{$array[1]} = "ori";
	$snp=shift(@array);
	$score = shift(@array);
	#$sum=0;
	chomp($score);
	if($score eq "")
	{
		$score = 'NA';
	}
	if(exists($file{$snp}))
	{
		$line = join(" ",@array);
		if($line =~ m/0/)
		{
			#print "not imputed\t$line\n";
			#$txt = "";
			if(exists($affy{$snp}) && exists($ill550v3{$snp}))
			{
				print WRBUFF "$snp\tnot imputed\tAFFY/ILL550v3\t$score\n";
				#print "sucess\tAFFY\n";
			}
			elsif(exists($affy{$snp}))
			{
				#print "sucess\tAFFY\n";
				print WRBUFF "$snp\tnot imputed\tAFFY\t$score\n";
			}
			elsif(exists($ill550v3{$snp}))
			{
				 print WRBUFF "$snp\tnot imputed\tILL550V3\t$score\n";
				#print "sucess\tILL550\n";
			}	
			else
			{
				#print "not from any platform $snp\n";
				print WRBUFF "not imputed\tNONE\n";
			}	
			
		}
		else
		{
			print WRBUFF "$snp\timputed\tHAPMAP\t$score\n";
		}
		#$sum = $line=~ tr/1/4/;
		#print $sum."\n";	
	}
}


